package main

import "fmt"

func main() {

	// 正常情况下 可读写
	var all_write_read_chan = make(chan int, 100)
	all_write_read_chan <- 100
	fmt.Println(<-all_write_read_chan)

	// 设置只可写
	var only_write_chan chan<- int
	only_write_chan = make(chan int, 100)
	only_write_chan <- 100
	//<-only_write_chan  // Invalid operation: <-only_write_chan (receive from the send-only type chan<- int)

	// 设置只读
	var only_read_chan <-chan int
	fmt.Println(<-only_read_chan)
	//only_read_chan<-9 // Invalid operation: only_read_chan<-9 (send to the receive-only type <-chan int)

}
